<template>
  <div class="content">
    <el-page-header :content="`订单号:${this.$route.params.id}`" @back="goBack" />
    <el-descriptions class="detail" title="主题订单" :column="2" border>
      <el-descriptions-item label="旅行" span="2">{{ order.title }}</el-descriptions-item>
      <el-descriptions-item label="订单创建时间" span="2">{{ order.creatTime }}</el-descriptions-item>
      <el-descriptions-item v-if="order.type" label="状态">
        <el-tag v-if="order.type.id === 1" type="success" size="small">{{ order.type.name }}</el-tag>
        <el-tag v-else-if="order.type.id === 2" size="small">{{ order.type.name }}</el-tag>
        <el-tag v-else type="danger" size="small">{{ order.type.name }}</el-tag>
      </el-descriptions-item>
      <el-descriptions-item label="消费">{{ order.price }}￥</el-descriptions-item>
      <el-descriptions-item label="出发日期">{{ order.beginDate }}</el-descriptions-item>
      <el-descriptions-item label="结束日期">{{ order.endDate }}</el-descriptions-item>
      <el-descriptions-item label="大人">{{ order.adultNum }}(人)</el-descriptions-item>
      <el-descriptions-item label="小孩">{{ order.childNum }}(人)</el-descriptions-item>
      <el-descriptions-item label="出发地点">{{ order.begin }}</el-descriptions-item>
      <el-descriptions-item label="结束地点">{{ order.end }}</el-descriptions-item>
    </el-descriptions>

    <el-descriptions v-if="user" class="detail" title="用户详情" :column="3" border>
      <el-descriptions-item label="用户id">{{ user.id }}</el-descriptions-item>
      <el-descriptions-item label="用户名">{{ user.name }}</el-descriptions-item>

    </el-descriptions>
    <el-descriptions v-if="travel" class="detail" title="旅行详情" :column="3" border>
      <el-descriptions-item label="旅行" span="3">{{ travel.name }}</el-descriptions-item>
      <el-descriptions-item label="旅行id">{{ travel.id }}</el-descriptions-item>
      <el-descriptions-item label="价钱">{{ travel.price }}￥</el-descriptions-item>
      <el-descriptions-item label="旅行天数">{{ travel.days }}</el-descriptions-item>
      <el-descriptions-item label="旅行起点">{{ travel.beginning }}</el-descriptions-item>
      <el-descriptions-item label="旅行主题">{{ travel.travelTheme.name }}</el-descriptions-item>
      <el-descriptions-item label="旅行方式">{{ travel.travelWay.name }}</el-descriptions-item>

    </el-descriptions>
  </div>
</template>

<script>
import { queryTravelOrderById } from '@/api/order'
import { global } from '@/utils/global'
export default {
  data() {
    return {
      tableLoading: false,
      order: {},
      user: {},
      travel: {
        travelTheme: {},
        travelWay: {}
      }
    }
  },
  created() {
    global.$emit('changeTitle', `订单号:${this.$route.params.id}`)
    this.queryTravelOrderById()
  },
  methods: {
    goBack() {
      this.$router.go(-1)
    },
    queryTravelOrderById() {
      this.tableLoading = true
      queryTravelOrderById(this.$route.params.id).then(res => {
        this.order = res.data
        this.travel = this.order.travel
        this.user = this.order.user
      }).finally(() => {
        this.tableLoading = false
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.detail{
  margin-top: 24px;
}
</style>
